# Maintainer: Sven-Hendrik Haase <svenstaro@archlinux.org>
# Contributor: Aleksandar Trifunović <akstrfn at gmail dot com>

_pkgname=GSL
pkgname=microsoft-gsl
pkgver=4.0.0
pkgrel=1
pkgdesc="C++ Core Guidelines Support Library"
arch=('any')
url="https://github.com/Microsoft/GSL"
license=('MIT')
makedepends=('cmake' 'git' 'ninja')
source=("$pkgname-$pkgver.tar.gz::https://github.com/Microsoft/GSL/archive/v${pkgver}.tar.gz")
sha256sums=('f0e32cb10654fea91ad56bde89170d78cfbf4363ee0b01d8f097de2ba49f6ce9')

build() {
    cd "$_pkgname-$pkgver"
    cmake \
        -Bbuild \
        -GNinja \
        -DGSL_TEST=ON \
        -DCMAKE_CXX_FLAGS="${CXXFLAGS}" \
        -DCMAKE_EXE_LINKER_FLAGS="${LDFLAGS}" \
        -DCMAKE_INSTALL_PREFIX=/usr \
        -DCMAKE_BUILD_TYPE=Release
    ninja -C build
}

check() {
    cd "$_pkgname-$pkgver"
    ninja -C build test
}

package() {
    cd "$_pkgname-$pkgver"
    DESTDIR="$pkgdir/" ninja -C build install
    install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}
